Hi. I have a compiling error which doesn't seem to want to go away. I suppose I could try to do it another way, but it seems really annoying that it is not working and I'm not sure why.
The code is compiled with gcc. I'm just compiling the object code now - not yet linking it into the program. Here is the compiler error:
Code:
bash-3.00$ gcc -c menu_browser.c
menu_browser.c: In function create_menu_browser_ctrl:
menu_browser.c:10: error: expected expression before { token
Here is the offending source file, menu_browser.c:
Code:
#include <stdlib.h>
#include <pthread.h>
#include "menu_data.h"
#include "menu_browser.h"
#include "disp_thread_modes.h"
struct Menu_Browser_Ctrl * create_menu_browser_ctrl(MenuItem_List_Bundle * menuitem_list_bundle)
{
struct Menu_Browser_Ctrl * menu_browser_ctrl = malloc(sizeof(struct Menu_Browser_Ctrl));
menu_browser_ctrl->mode_h = PTHREAD_MUTEX_INITIALIZER;
menu_browser_ctrl->mode = th_m_dead;
menu_browser_ctrl->menuitem_list_bundle = menuitem_list_bundle;
return menu_browser_ctrl;
}
If I comment out the line with "PTHREAD_MUTEX..." in it, the source compiles fine, so I'm (wildly) guessing that this has something to do with the PTHREAD_MUTEX_INITIALIZER macro.
Here is menu_browser.h:
Code:
#ifndef _MENU_BROWSER_
#define _MENU_BROWSER_
#include <pthread.h>
#include "menu_data.h"
struct Menu_Browser_Ctrl {
pthread_mutex_t mode_h;
char mode;
struct m_i_l_b * menuitem_list_bundle;
};
struct Menu_Browser_Ctrl * create_menu_browser_ctrl(MenuItem_List_Bundle * menuitem_list_bundle);
#endif
"menu_data.h" is kind of long, but it provides typedef struct
MenuItem_List_Bundle. "disp_thread_modes.h" simply provides a few constants.